package com.stylefeng.guns.rest.modular.wz.api.v3.dao;

import com.stylefeng.guns.rest.common.persistence.dao.WzCouponMapper;
import com.stylefeng.guns.rest.common.persistence.dao.WzCouponOrderMapper;
import com.stylefeng.guns.rest.common.persistence.dao.WzMapActivityMapper;
import com.stylefeng.guns.rest.common.persistence.model.*;
import com.stylefeng.guns.rest.modular.wz.service.IWzUserFinanceRecordService;
import com.stylefeng.guns.rest.modular.wz.service.IWzUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: wz_dev_app_shop
 * @description:
 * @author: Chenchao
 * @create: 2019-01-15 18:22
 **/
@Service
public class WzCouponDaoImpl {
    @Autowired
    private IWzUserFinanceRecordService userFinanceRecordService;
    @Autowired
    private IWzUserService userService;
    @Autowired
    private WzCouponOrderMapper couponOrderMapper;
    @Autowired
    private WzMapActivityMapper mapActivityMapper;
    @Autowired
    private WzCouponMapper couponMapper;


    @Transactional
    public boolean addMapActivityUsedCoupon(WzMapActivity mapActivity, WzCouponOrder couponOrder) {
        int r = mapActivityMapper.insert(mapActivity);
        if (r > 0) {
            r = couponOrderMapper.updateById(couponOrder);
            if (r > 0) {
                return true;
            }
        }
        return false;
    }

}
